package com.ch.forum.service.impl;

import com.ch.forum.bo.ResponseResult;
import com.ch.forum.dao.SystemParamMapper;
import com.ch.forum.service.SystemParamService;
import com.ch.forum.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SystemParamServiceImpl implements SystemParamService {

    @Autowired
    private SystemParamMapper systemParamMapper;

    @Override
    public String findValueByName(String name) {
        return systemParamMapper.findValueByName(name);
    }

    @Override
    public ResponseResult findAll() {
        return new ResponseResult(true, "数据", systemParamMapper.findAll());
    }

    @Override
    public ResponseResult updateValue(String name, String value) {
        String sql = systemParamMapper.findValueByName(name);
        if(StringUtils.isEmpty(sql)){
            return new ResponseResult(false,"参数不存在");
        }
        systemParamMapper.updateValue(name, value);
        return new ResponseResult(true, "修改成功");
    }
}
